// 导出页面为PDF格式
import html2Canvas from 'html2canvas'
import JsPDF from 'jspdf'
export default{
  install (Vue, options) {
    Vue.prototype.getPdf = function () {
      const title = '事件详情信息';

      html2Canvas(document.querySelector('#pdfDom'), {
        allowTaint: true
      }).then(function (canvas) {
          let contentWidth = canvas.width
          let contentHeight = canvas.height
          let imgWidth = 595.28
          let imgHeight = 595.28 / contentWidth * contentHeight
          let pageData = canvas.toDataURL('image/png', 1.0)
          let PDF = new JsPDF('', 'pt', 'a4')
          PDF.addImage(pageData, 'png', 0, 0, imgWidth, imgHeight)
          PDF.save(title + '.pdf')
        }
      )
    }
  }
}
